package com.civil.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class DataResponse {

	private Integer code;

	private String msg;

	@JsonInclude(Include.NON_NULL)
	private Object data;
	
	@JsonInclude(Include.NON_NULL)
	private Integer count;

	private boolean success;

	public static DataResponse isOk(Object data) {

		return new DataResponse(MsgType.IsOk.getValue(), MsgType.IsOk.getRemark(), data, true,null);
	}

	public static DataResponse isOk(Object data, Integer count) {

		return new DataResponse(MsgType.IsOk.getValue(), MsgType.IsOk.getRemark(), data,true, count);
	}

	public static DataResponse isOk(Integer status, Object data) {

		return new DataResponse(status, MsgType.IsOk.getRemark(), data, true,null);
	}

	public static DataResponse isOk() {
		return new DataResponse(MsgType.IsOk.getValue(), MsgType.IsOk.getRemark(), true);
	}

	public static DataResponse ErrorMsg() {
		return new DataResponse(MsgType.Error.getValue(), MsgType.Error.getRemark(), false);
	}

	public static DataResponse ErrorMsg(Object data) {
		return new DataResponse(MsgType.Error.getValue(), MsgType.Error.getRemark(), data, false,null);
	}

	public static DataResponse ErrorMsg(Integer status, Object data) {
		return new DataResponse(status, MsgType.Error.getRemark(), data, false,null);
	}

	public DataResponse() {
		super();
	}

	public DataResponse(Integer status, String msg, boolean success) {
		super();
		this.code = status;
		this.msg = msg;
		this.success = success;
	}

	public DataResponse(Integer status, String msg, Object data, boolean success,Integer count) {
		super();
		this.code = status;
		this.msg = msg;
		this.data = data;
		this.count = count;
		this.success = success;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}
	 

}
